Skip to content

Missing the obvious <?php #9358

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 1 commit into from
Closed

Missing the obvious <?php #9358

wants to merge 1 commit into from

Conversation

nasaralla
Copy link
Contributor

Simple missing <?php had me wondering for an hour

Simple missing <?php had me wondering for an hour
@javiereguiluz
Copy link
Member

@nasaralla thanks for your first contribution to this repository. However, this is not really an error but a decision. We decided to not include any PHP opening tag in the docs (here you have more details: #8324 (comment)) Other frameworks do the same in their docs.


Now a comment directed at the people who manage this repository: @weaverryan, @xabbuh, @wouterj and @HeahDude. What do you think about adding <?php just to this article which is the first one that Symfony newcomers read?

In 2015 some people asked us to add it (#5741) but we said no.

In 2016 some people asked us to add it (#6389) but we said no.

In 2017 some people asked us to add it (#8324) but we said no.

When lots of people ask you to change your decision ... you probably made a wrong decision.

@HeahDude
Copy link
Contributor

The reasons for closing #5741 are still valid IMO.
What about a little Prerequisite section dedicated to new comers that we could link in the introduction of some guides to explain that Symfony cannot be mastered without basic knowledge of PHP with a link to its docs and where we could mention that we make use of a ton of code examples without explicit opening tag.

@javiereguiluz
Copy link
Member

I don't think they'll read an external document. The thing is that if you are a newcomer and reading the first tutorial of some project, you probably copy+paste things without much thinking to test them in your browser. That's why I do at least 😅 , so I expect my first copy+paste to work perfectly.

@theofidry
Copy link
Contributor

I also think like @javiereguiluz that the first read is worth special attention and may warrant a different policy

@HeahDude
Copy link
Contributor

This may also give a bad habit :), and can be frustrating when the first works and not the others.

I have no hard feeling on this, but my point is that we better learn from mistakes than from things working out of the box.
We should not copy/paste code without trying to understand if it's what we expect, people doing so should make the mistake to understand it and not do it anymore.
For that I would not change this example.

Again, I'm fine either way, just expressing another opinion here :).

@theofidry
Copy link
Contributor

Sure, but when you doubt, things are not working and you do exactly as said in the docs and it's not working, it's a desperate situation and if it's only for one <?php tag it's really infuriating :)

But I do think it's only valid for that specific page.

@nasaralla
Copy link
Contributor Author

Well for me I am doing php for 9 / 10 years ... and even I didn't spot that

@weaverryan
Copy link
Member

+1 for adding it to the intro docs. And maybe to other docs later, but let’s start there. I have always seen people copy code in trainings and try to debug their missing open php tag (which is really tricky). Just last month it happened to maybe 10% if a conference workshop.

I think it’s time to be pragmatic.

@xabbuh
Copy link
Member

xabbuh commented Mar 4, 2018

Could we add this automatically when PHP code blocks are rendered?

@javiereguiluz
Copy link
Member

javiereguiluz commented Mar 4, 2018

@xabbuh that's actually a very nice idea. I've put together some quick CSS styles:

.highlight-php .highlight pre {
    position: relative;
    padding-top: 30px;
}
.highlight-php .linenos {
    padding-top: 30px;
}
.highlight-php .highlight pre::before{
    content: "<?php";
    color: #999;
    position: absolute;
    top: 5px
}

And this is how it looks:

php-listing


There's a problem though: content generated via CSS is not selectable 😢

@javiereguiluz
Copy link
Member

Let's merge this "as is" and we'll add more opening tags if needed. @nasaralla thanks for improving the docs for newcomers and congrats on your fitst Symfony Docs contribution. We merged it on 2.7 branch, the oldest maintained branch, and we'll merge it up later. That's why GitHub displays it as closed instead of merged, but it's merged.

javiereguiluz added a commit that referenced this pull request Mar 7, 2018
This PR was submitted for the 4.0 branch but it was merged into the 2.7 branch instead (closes #9358).

Discussion
----------

Missing the obvious <?php

Simple missing <?php had me wondering for an hour

Commits
-------

261dd81 Missing the obvious <?php
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants